package com.chengh.nami.common.exception;

import com.chengh.nami.common.response.ResponseCodeEnum;
import lombok.Getter;
import lombok.Setter;

/**
 * @author chengh
 * 自定义异常类
 */
@Getter
@Setter
public class BizException extends RuntimeException{

    private final static long serialVersionUID = 1L;

    private Integer errorCode;

    private String errorMsg;

    public BizException(String message) {
        // message用于用户设置抛出错误详情，例如：当前价格-5，小于0
        super(message);
        // 状态码
        this.errorCode = ResponseCodeEnum.ERROR.getCode();
        // 状态码配套的msg
        this.errorMsg = message;
    }

    public BizException(Integer code, String message) {
        // message用于用户设置抛出错误详情，例如：当前价格-5，小于0
        super(message);
        // 状态码
        this.errorCode = code;
        // 状态码配套的msg
        this.errorMsg = message;
    }

    public BizException(ResponseCodeEnum responseCodeEnum, String message) {
        // message用于用户设置抛出错误详情，例如：当前价格-5，小于0
        super(message);
        // 状态码
        this.errorCode = responseCodeEnum.getCode();
        // 状态码配套的msg
        this.errorMsg = message;
    }
}
